﻿<?php
// Luu linh vuc hien thoi
//if(isset($_REQUEST['cate_id'])){
	//$v_cate_id = intval($_REQUEST['cate_id']);
//} 
?>
<table width="100%" cellpadding="0" cellspacing="0">
	<form action="index.php" method="post" name="frm_dsp_all_cate_by_agency">
	<input name="fuseaction" type="hidden" value="">
	<input type="hidden" name="cate_id" value="<?php echo $v_cate_id;?>">
	<tr><td height="5"></td></tr><?php 
	if (sizeof($arr_all_agency) > 0){
		$v_number_of_agency = sizeof($arr_all_agency);
		$v_cate_name= $arr_all_agency['0']['0'];
		$v_cate_id= $arr_all_agency['0']['3'];
	}?>
	<tr class="page_title">
		<td colspan="3"><?php echo CONST_AF_SEARCH_BY_CATE_LABEL.">>".$v_cate_name;?></td>
	</tr>
	<tr><td height="20"></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td class="normal_label" ><?php echo CONST_CATE_SELECT_LABEL; ?></td>
		<td class="normal_label" colspan="3">
		  <select name="sel_cate" class="normal_selectbox" onChange="show_agency_by_cate();">                
			<?php echo _generate_select_option($arr_all_cate,'0','0','2', $v_cate_id);?>
		  </select></td>			
	</tr>
	<tr><td height="5"></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0"><?php
	if ($v_number_of_agency > 0){
		$current_pos=0; // vi tri hien thoi 
				//So vong lap de lay danh sach CQHC con
				$total_loop= $v_number_of_agency;
				$haft_loop= round($total_loop/2); // mot nua vong lap
				for($i=0;$i< $haft_loop;$i++){//(****)
					$j= $current_pos + $i; // vi tri lay CQHC
					// day CQHC ben trai
					$v_left_agency_id = $arr_all_agency[$j]['1'];
					$v_left_agency_name= $arr_all_agency[$j]['2'];	
					$v_left_number_af=$arr_all_agency[$j]['4'];					
					$v_left_agency_url = "index.php?fuseaction=DISPLAY_ALL_AF_BY_AGENCY&v_session=".$v_session."&agency_id=" . $v_left_agency_id . "&cate_id=".$v_cate_id;
					// day CQHC ben phai
					$right_index= $j+ $haft_loop;  // vi tri lay CQHC o day ben phai
					if(($right_index- $current_pos) < $total_loop){
						$v_right_agency_id = $arr_all_agency[$right_index]['1'];
						$v_right_agency_name = $arr_all_agency[$right_index]['2'];
						$v_right_number_af=$arr_all_agency[$right_index]['4'];						
						$v_right_agency_url = "index.php?fuseaction=DISPLAY_ALL_AF_BY_AGENCY&v_session=".$v_session."&agency_id=" . $v_right_agency_id . "&cate_id=".$v_cate_id;
					}?>
				
					<tr > 
					<col width="42%"><col width="43%"><col width="15%">
						<td>
						<img src="<?php echo $_ISA_IMAGE_URL_PATH?>open.gif" >
							<a  href="<?php echo $v_left_agency_url;?>"><?php echo $v_left_agency_name;?></a><? echo " (".$v_left_number_af.")";?>
						</td><?php
						if(($right_index- $current_pos) < $total_loop){?>	
							<td>
							<img src="<?php echo $_ISA_IMAGE_URL_PATH?>open.gif">
								<a  href="<?php echo $v_right_agency_url;?>"><?php echo $v_right_agency_name;?></a><? echo " (".$v_right_number_af.")";?>
							</td><?php
						}?>	
						<td></td>
					</tr><?php 
				}//(****)
			$current_pos= $current_pos + $total_loop; }?>
	<tr><td height="200"></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr><td>&nbsp;</td></tr>
	<tr>
		<td align="center"><a class="normal_button" href="<?php echo $_URL_BACK?>"><?php echo _CONST_BACK_BUTTON; ?></a></td>
	</tr>
</table>
